package com.lanhai.zhonglai;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;

import com.google.gson.Gson;

public class MsgHandler   extends IoHandlerAdapter{
 
	Gson gson;
	public MsgHandler() {
		gson=new Gson();
	}
	
	
	@Override
	public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
		session.write("1");
	}


	@Override
	public void sessionOpened(IoSession session) throws Exception {
		String login="username=sys&src=svr";
		session.write(login);
		System.out.println("tcp连接成功");
	}

 
	@Override
	public void sessionClosed(IoSession session) throws Exception { 
		System.out.println("关闭了");
	}


	@Override
	public void messageReceived(IoSession session, Object message) throws Exception {
		
		String msg=message.toString();
		System.out.println(msg); 
	}
 

}